package com.xunji.user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xunji.user.util.RequestContextUtil;
import com.xunji.user.vo.req.OrgAddRequest;
import com.xunji.user.vo.req.OrgUpdateRequest;
import lombok.Data;

import java.time.LocalDateTime;

@TableName(value = "t_lp_org")
@Data
public class Org {

    @TableId(value = "ID", type = IdType.AUTO)
    private Integer id;

    private String name;

    private Integer pId;

    private Integer weight;

    private String investigationTeam; // 调查组（备用字段）

    private String createdBy;

    private LocalDateTime createdTime;

    public static Org getInstance(OrgAddRequest request) {
        Org org = new Org();
        org.setName(request.getName());
        org.setPId(request.getParentId());
        org.setWeight(request.getWeight());
        org.setCreatedTime(LocalDateTime.now());
        return org;
    }

    public static Org getInstance(OrgUpdateRequest request) {
        Org org = new Org();
        org.setId(request.getId());
        //org.setPId(request.getPId());
        org.setName(request.getName());
        return org;
    }

}
